﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
                    xmlns:exc="clr-namespace:CPPEI.Coolzon.UI"
                    xmlns:local="clr-namespace:CPPEI.Coolzon.UI">


    <!-- Type converters-->
    <local:True2VisibleConverter x:Key="true2Visible"/>
    <local:True2HiddenConverter x:Key="true2Hidden"/>
    <local:ImageOffsetConverter x:Key="imageOffsetConverter" />
    <local:RadiusToDiameterConverter x:Key="radiusToDiameterConverter"/>
    <local:PointerCenterConverter x:Key="pointerCenterConverter"/>
    <local:RangeIndicatorLightPositionConverter x:Key="rangeIndicatorLightPositionConverter"/>
    <local:SizeConverter x:Key="sizeConverter" />
    <local:BackgroundColorConverter x:Key="backgroundColorConverter" />
    <local:GlassEffectWidthConverter x:Key="glassEffectWidthConverter" />
    <local:ColorToSolidColorBrushConverter x:Key="colorToSolidColorBrushConverter" />
    <local:ImageSourceFileToImageSource x:Key="imageSourceFileToImageSource"/>
    <local:BrushExToBrush  x:Key="brushExToBrush"/>

    <Style TargetType="local:Part">
        <Setter Property="Template" >
            <Setter.Value>
                <ControlTemplate TargetType="local:Part">
                    <Grid Margin="{TemplateBinding XMargin}" Background="{TemplateBinding XBackground, Converter={StaticResource brushExToBrush}}"
                          Visibility="{TemplateBinding XIsVisible, Converter={StaticResource true2Visible}}">

                        <Border BorderBrush="{TemplateBinding XBorderBrush, Converter={StaticResource brushExToBrush}}" BorderThickness="{TemplateBinding XBorderThickness}">

                        </Border>
                        <Image Source="{TemplateBinding XBackgroundImage,Converter={StaticResource imageSourceFileToImageSource}}" Margin="{TemplateBinding XBorderThickness}"/>
                        <Grid Margin="{TemplateBinding XBorderThickness}">
                            <Grid Margin="{TemplateBinding XPadding}">
                                <ContentPresenter Name="contentPresenter" Content="{TemplateBinding Content}"/>
                                <ContentPresenter Name="ToolbarContent" Content="{TemplateBinding ToolbarContent}"/>
                            </Grid>
                        </Grid>
                        <Grid Background="#01000000" Visibility="{TemplateBinding Property=XIsDesignMode,Converter={StaticResource true2Visible}}"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--<Style TargetType="local:ControlPart">
        <Setter Property="Template" >
            <Setter.Value>
                <ControlTemplate TargetType="local:ControlPart">
                    <Grid Margin="{TemplateBinding Margin}">
                        <Image Source="{TemplateBinding BackgroundImageSource}"/>
                        <Grid Margin="{TemplateBinding Padding}">
                            <ContentPresenter Name="contentPresenter" Content="{TemplateBinding Content}"/>
                            <ContentPresenter Name="ToolbarContent" Content="{TemplateBinding ToolbarContent}"/>
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>-->

    <Style TargetType="local:PartFrame">
        <Setter Property="Template" >
            <Setter.Value>
                <ControlTemplate TargetType="local:PartFrame">
                    <Grid Background="{TemplateBinding XBackground, Converter={StaticResource brushExToBrush}}" ClipToBounds="True">
                        <ContentPresenter Name="contentPresenter" 
                                          Content="{TemplateBinding Content}"
                                          
                                          Margin="{TemplateBinding XBorderThickness}"/>
                        <!-- 放大镜 -->
                        <Canvas Name="_ctlMagnifyContainer" Visibility="{TemplateBinding XIsShowMagnify,Converter={StaticResource true2Visible}}">
                            <Grid Name="_ctlMagnify"
                                  Canvas.Left="{TemplateBinding XMagnifyLeft}"
                                  Canvas.Top="{TemplateBinding XMagnifyTop}">
                                <Ellipse Width="800" Height="800" Name="magnifierEllipse" Fill="{TemplateBinding XMagnifySource}" />
                                <Grid>
                                    <Ellipse Stroke="Black" StrokeThickness="2">
                                        <Ellipse.Effect>
                                            <BlurEffect Radius="10"/>
                                        </Ellipse.Effect>
                                    </Ellipse>
                                    <Ellipse Stroke="DarkBlue" StrokeThickness="2" />
                                </Grid>
                            </Grid>
                        </Canvas>
                        <Canvas Name="_ctlLaserPointContainer" Visibility="{TemplateBinding XIsShowLaserPointer,Converter={StaticResource true2Visible}}">
                            <Grid Name="_ctlLaserPoint"
                                  Canvas.Left="{TemplateBinding XLaserPointerLeft}"
                                  Canvas.Top="{TemplateBinding XLaserPointerTop}">
                                <Grid Width="90" Height="90" Name="_ctlLaserPointEllipse">
                                    <Grid.Effect>
                                        <BlurEffect Radius="3"/>
                                    </Grid.Effect>
                                    <Image Source="/CPPEI.Coolzon.UI;component/Res/laserpoint.png"/>
                                </Grid>
                            </Grid>
                        </Canvas>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style TargetType="local:AreaPart">
        <Setter Property="Template" >
            <Setter.Value>
                <ControlTemplate TargetType="local:AreaPart">
                    <Grid Background="{TemplateBinding XBackground, Converter={StaticResource brushExToBrush}}" 
                          Visibility="{TemplateBinding XIsVisible, Converter={StaticResource true2Visible}}">

                        <Image Source="{TemplateBinding XBackgroundImage,Converter={StaticResource imageSourceFileToImageSource}}"/>
                        <Grid Margin="{TemplateBinding XPadding}">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <Grid Grid.Row="0" Visibility="{TemplateBinding Property=XIsShowHeader,Converter={StaticResource true2Visible}}" HorizontalAlignment="Left">
                                <Image Source="{TemplateBinding XHeaderBackgroundImage,Converter={StaticResource imageSourceFileToImageSource}}" Stretch="Fill" Width="{TemplateBinding XHeaderWidth}" Height="{TemplateBinding XHeaderHeight}"/>
                                <Border BorderBrush="Gray" BorderThickness="0" Padding="{TemplateBinding XHeaderPadding}" HorizontalAlignment="Left" Width="{TemplateBinding XHeaderWidth}" Height="{TemplateBinding XHeaderHeight}">
                                    <TextBlock Text="{TemplateBinding XHeader}" FontFamily="{TemplateBinding XHeaderFont}" FontSize="{TemplateBinding XHeaderFontSize}" Foreground="{TemplateBinding XHeaderForeground, Converter={StaticResource brushExToBrush}}" VerticalAlignment="Center"/>
                                </Border>
                            </Grid>
                            <Border Grid.Row="1" BorderBrush="{TemplateBinding XBorderBrush, Converter={StaticResource brushExToBrush}}" BorderThickness="{TemplateBinding XBorderThickness}">

                            </Border>
                            <ContentPresenter Name="contentPresenter" Content="{TemplateBinding Content}" Grid.Row="1" Margin="{TemplateBinding XBorderThickness}"/>
                            <ContentPresenter Name="ToolbarContent" Content="{TemplateBinding ToolbarContent}" Grid.Row="1" Margin="{TemplateBinding XBorderThickness}"/>
                        </Grid>
                        <Grid Background="#01000000" Visibility="{TemplateBinding Property=XIsDesignMode,Converter={StaticResource true2Visible}}"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="local:ScenePart">
        <Setter Property="Template" >
            <Setter.Value>
                <ControlTemplate TargetType="local:ScenePart">
                    <Grid Background="{TemplateBinding XBackground, Converter={StaticResource brushExToBrush}}" Opacity="{TemplateBinding Opacity}" ClipToBounds="True"
                          Visibility="{TemplateBinding XIsVisible, Converter={StaticResource true2Visible}}">
                        <!--<Border Background="#55FF0000" BorderBrush="Red" BorderThickness="1" IsHitTestVisible="False"></Border>-->
                        <Canvas>
                            <Grid Name="loopRect" Canvas.Left="{TemplateBinding HVirtualLoopOffset}"
                                       Width="{Binding ActualWidth, ElementName=actualContentContainer}"
                                       Height="{Binding ActualHeight, ElementName=actualContentContainer}"
                                       Visibility="{TemplateBinding Property=IsHorizontalLoopRender,Converter={StaticResource true2Visible}}">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*"/>
                                    <RowDefinition Height="*"/>
                                </Grid.RowDefinitions>
                                <Rectangle Grid.Column="0" Grid.Row="0">
                                    <Rectangle.Fill>
                                        <VisualBrush Visual="{Binding ElementName=actualContentContainer}" TileMode="None" Stretch="None">
                                            <VisualBrush.Viewbox>
                                                <Rect X="0" Y="0" Width="0.25" Height="0.5"/>
                                            </VisualBrush.Viewbox>
                                        </VisualBrush>
                                    </Rectangle.Fill>
                                </Rectangle>
                                <Rectangle Grid.Column="1" Grid.Row="0">
                                    <Rectangle.Fill>
                                        <VisualBrush Visual="{Binding ElementName=actualContentContainer}" TileMode="None" Stretch="None">
                                            <VisualBrush.Viewbox>
                                                <Rect X="0.25" Y="0" Width="0.25" Height="0.5"/>
                                            </VisualBrush.Viewbox>
                                        </VisualBrush>
                                    </Rectangle.Fill>
                                </Rectangle>
                                <Rectangle Grid.Column="2" Grid.Row="0">
                                    <Rectangle.Fill>
                                        <VisualBrush Visual="{Binding ElementName=actualContentContainer}" TileMode="None" Stretch="None">
                                            <VisualBrush.Viewbox>
                                                <Rect X="0.5" Y="0" Width="0.25" Height="0.5"/>
                                            </VisualBrush.Viewbox>
                                        </VisualBrush>
                                    </Rectangle.Fill>
                                </Rectangle>
                                <Rectangle Grid.Column="3" Grid.Row="0">
                                    <Rectangle.Fill>
                                        <VisualBrush Visual="{Binding ElementName=actualContentContainer}" TileMode="None" Stretch="None">
                                            <VisualBrush.Viewbox>
                                                <Rect X="0.75" Y="0" Width="0.25" Height="0.5"/>
                                            </VisualBrush.Viewbox>
                                        </VisualBrush>
                                    </Rectangle.Fill>
                                </Rectangle>
                                <Rectangle Grid.Column="0" Grid.Row="1">
                                    <Rectangle.Fill>
                                        <VisualBrush Visual="{Binding ElementName=actualContentContainer}" TileMode="None" Stretch="None">
                                            <VisualBrush.Viewbox>
                                                <Rect X="0" Y="0.5" Width="0.25" Height="0.5"/>
                                            </VisualBrush.Viewbox>
                                        </VisualBrush>
                                    </Rectangle.Fill>
                                </Rectangle>
                                <Rectangle Grid.Column="1" Grid.Row="1">
                                    <Rectangle.Fill>
                                        <VisualBrush Visual="{Binding ElementName=actualContentContainer}" TileMode="None" Stretch="None">
                                            <VisualBrush.Viewbox>
                                                <Rect X="0.25" Y="0.5" Width="0.25" Height="0.5"/>
                                            </VisualBrush.Viewbox>
                                        </VisualBrush>
                                    </Rectangle.Fill>
                                </Rectangle>
                                <Rectangle Grid.Column="2" Grid.Row="1">
                                    <Rectangle.Fill>
                                        <VisualBrush Visual="{Binding ElementName=actualContentContainer}" TileMode="None" Stretch="None">
                                            <VisualBrush.Viewbox>
                                                <Rect X="0.5" Y="0.5" Width="0.25" Height="0.5"/>
                                            </VisualBrush.Viewbox>
                                        </VisualBrush>
                                    </Rectangle.Fill>
                                </Rectangle>
                                <Rectangle Grid.Column="3" Grid.Row="1">
                                    <Rectangle.Fill>
                                        <VisualBrush Visual="{Binding ElementName=actualContentContainer}" TileMode="None" Stretch="None">
                                            <VisualBrush.Viewbox>
                                                <Rect X="0.75" Y="0.5" Width="0.25" Height="0.5"/>
                                            </VisualBrush.Viewbox>
                                        </VisualBrush>
                                    </Rectangle.Fill>
                                </Rectangle>
                            </Grid>
                            <Grid Name="actualContentContainer"
                                  Width="{TemplateBinding XWidth}"
                                  Height="{TemplateBinding XHeight}"
                                  ClipToBounds="True"
                                  Canvas.Left="{TemplateBinding HActualLoopOffset}" Background="#01000000">
                                <Image Source="{TemplateBinding XBackgroundImage,Converter={StaticResource imageSourceFileToImageSource}}"/>
                                <ContentPresenter Name="contentPresenter" Content="{TemplateBinding Content}"/>
                            </Grid>
                            <!--<Rectangle Name="loopRect" Canvas.Left="{TemplateBinding HVirtualLoopOffset}"
                                       Width="{Binding ActualWidth, ElementName=actualContentContainer}"
                                       Height="{Binding ActualHeight, ElementName=actualContentContainer}"
                                       Visibility="{TemplateBinding Property=IsHorizontalLoopRender,Converter={StaticResource true2Visible}}"
                                       RenderOptions.BitmapScalingMode="HighQuality">
                                <Rectangle.Fill>
                                    <VisualBrush Visual="{Binding ElementName=actualContentContainer}" TileMode="None"/>
                                </Rectangle.Fill>
                            </Rectangle>-->
                        </Canvas>
                        <Grid>
                            <ContentPresenter Name="ToolbarContent" Content="{TemplateBinding ToolbarContent}"/>
                        </Grid>
                        <!--<Grid HorizontalAlignment="Left" VerticalAlignment="Top">
                            <StackPanel>
                                <TextBlock Text="{Binding ActualWidth, ElementName=actualContentContainer}"/>
                                <TextBlock Text="{Binding ActualHeight, ElementName=actualContentContainer}"/>
                                <TextBlock Text="{Binding ActualWidth, ElementName=contentPresenter}"/>
                                <TextBlock Text="{Binding ActualHeight, ElementName=contentPresenter}"/>
                                <TextBlock Text="{Binding ActualWidth, ElementName=loopRect}"/>
                                <TextBlock Text="{Binding ActualHeight, ElementName=loopRect}"/>
                            </StackPanel>
                        </Grid>-->
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="local:ActiveXPart">
        <Setter Property="Template" >
            <Setter.Value>
                <ControlTemplate TargetType="local:ActiveXPart">
                    <Grid Margin="{TemplateBinding Margin}" Background="{TemplateBinding XBackground, Converter={StaticResource brushExToBrush}}" Opacity="{TemplateBinding Opacity}"
                          Visibility="{TemplateBinding XIsVisible, Converter={StaticResource true2Visible}}">
                        <Grid Visibility="{TemplateBinding Property=IsShowActiveX,Converter={StaticResource true2Hidden}}" Background="#01000000">
                            <TextBlock Text="组件已设置不显示ActiveX组件"
                                       HorizontalAlignment="Center"
                                       VerticalAlignment="Center"/>
                        </Grid>
                        <Grid Visibility="{TemplateBinding Property=IsShowActiveX,Converter={StaticResource true2Visible}}">
                            <ContentPresenter Name="contentPresenter"
                                              Content="{TemplateBinding Content}"
                                              Visibility="{TemplateBinding Property=XIsFrozen,Converter={StaticResource true2Hidden}}"/>

                        </Grid>
                        <Image Name="visualMask" Width="{TemplateBinding ActualWidth}" Height="{TemplateBinding ActualHeight}"
                               Visibility="{TemplateBinding Property=XIsFrozen,Converter={StaticResource true2Visible}}"
                               Source="{TemplateBinding WrapperProjectionImageSource}"/>
                        <Grid Margin="{TemplateBinding Padding}">
                            <ContentPresenter Name="ToolbarContent" Content="{TemplateBinding ToolbarContent}"/>
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style TargetType="local:TabContainerPart">
        <Setter Property="Template" >
            <Setter.Value>
                <ControlTemplate TargetType="local:TabContainerPart">
                    <Grid Margin="{TemplateBinding XMargin}" Background="{TemplateBinding XBackground, Converter={StaticResource brushExToBrush}}">

                        <Image Source="{TemplateBinding XBackgroundImage,Converter={StaticResource imageSourceFileToImageSource}}"/>
                        <Grid Margin="{TemplateBinding XPadding}">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <Grid Grid.Row="0" HorizontalAlignment="Left" Margin="{TemplateBinding XHeaderBarPadding}">
                                <ContentPresenter Name="contentPresenterHeader" Content="{TemplateBinding HeaderContent}"/>
                            </Grid>
                            <ContentPresenter Name="contentPresenter" Content="{TemplateBinding Content}" Grid.Row="1" Margin="{TemplateBinding XBorderThickness}"/>
                            <ContentPresenter Name="ToolbarContent" Content="{TemplateBinding ToolbarContent}" Grid.Row="1" Margin="{TemplateBinding XBorderThickness}"/>
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="local:TabHeader">
        <Setter Property="Template" >
            <Setter.Value>
                <ControlTemplate TargetType="local:TabHeader">
                    <Grid>
                        <Grid Visibility="{TemplateBinding Property=IsSelected,Converter={StaticResource true2Hidden}}">
                            <Image Source="{TemplateBinding XHeaderBackgroundImage,Converter={StaticResource imageSourceFileToImageSource}}" Stretch="Fill" Width="{TemplateBinding XHeaderWidth}" Height="{TemplateBinding XHeaderHeight}"/>
                            <Border BorderBrush="Gray" BorderThickness="0"
                                    Padding="{TemplateBinding XHeaderPadding}"
                                    HorizontalAlignment="Left"
                                    Width="{TemplateBinding XHeaderWidth}"
                                    Height="{TemplateBinding XHeaderHeight}">
                                <TextBlock Text="{TemplateBinding Caption}"
                                           FontFamily="{TemplateBinding XHeaderFont}"
                                           FontSize="{TemplateBinding XHeaderFontSize}"
                                           Foreground="{TemplateBinding XHeaderForeground, Converter={StaticResource brushExToBrush}}"
                                           VerticalAlignment="Center"/>
                            </Border>
                        </Grid>
                        <Grid Visibility="{TemplateBinding Property=IsSelected,Converter={StaticResource true2Visible}}">
                            <Image Source="{TemplateBinding XActiveHeaderBackgroundImage,Converter={StaticResource imageSourceFileToImageSource}}" Stretch="Fill" Width="{TemplateBinding XActiveHeaderWidth}" Height="{TemplateBinding XActiveHeaderHeight}"/>
                            <Border BorderBrush="Gray" BorderThickness="0"
                                    Padding="{TemplateBinding XActiveHeaderPadding}"
                                    HorizontalAlignment="Left"
                                    Width="{TemplateBinding XActiveHeaderWidth}"
                                    Height="{TemplateBinding XActiveHeaderHeight}">
                                <TextBlock Text="{TemplateBinding Caption}" 
                                           FontFamily="{TemplateBinding XActiveHeaderFont}"
                                           FontSize="{TemplateBinding XActiveHeaderFontSize}"
                                           Foreground="{TemplateBinding XActiveHeaderForeground, Converter={StaticResource brushExToBrush}}"
                                           VerticalAlignment="Center"/>
                            </Border>
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>